package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * @Author Justin Parker
 * @Date 2024/7/17 0017 11:34
 * @Version 1.0
 */
public class PrintWriteDemoText01 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner scanner = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(
                new BufferedOutputStream(
                        new FileOutputStream("./note.txt",true//表示追加
                        )),true//表示自动刷新
        );
        while (true) {
            System.out.println("请输入内容：");
            String str = scanner.nextLine();

            if ("exit".equalsIgnoreCase(str)) {
                System.out.println("退出");
                break;
            }
            pw.println(str);
            System.out.println("写入成功！");
            scanner.close();
            pw.close();
        }




    }
}
